package net.learn.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import net.learn.framework.common.page.PageResult;
import net.learn.framework.common.service.impl.BaseServiceImpl;
import net.learn.system.convert.SysRadioConvert;
import net.learn.system.convert.SysRadioDetailConvert;
import net.learn.system.dao.SysRadioDao;
import net.learn.system.dao.SysRadioDetailDao;
import net.learn.system.entity.SysRadioDetailEntity;
import net.learn.system.entity.SysRadioEntity;
import net.learn.system.query.SysRadioDetailQuery;
import net.learn.system.query.SysRadioQuery;
import net.learn.system.service.SysRadioDetailService;
import net.learn.system.service.SysRadioService;
import net.learn.system.utils.UUIDUtil;
import net.learn.system.vo.SysRadioDetailVO;
import net.learn.system.vo.SysRadioVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 李立志
 * @since 2022-04-01
 */
@Service
@AllArgsConstructor
public class SysRadioDetailServiceImpl extends BaseServiceImpl<SysRadioDetailDao, SysRadioDetailEntity> implements SysRadioDetailService {

    @Override
    public Boolean addRadioDetail(SysRadioDetailVO vo){
        SysRadioDetailEntity entity = SysRadioDetailConvert.INSTANCE.convert(vo);
        String uuid= UUIDUtil.uuid();
        entity.setUid(uuid);
        return baseMapper.insert(entity)>0;
    }
    @Override
    public Boolean updateRadioDetail(SysRadioDetailVO vo){
        SysRadioDetailEntity entity = SysRadioDetailConvert.INSTANCE.convert(vo);
        return baseMapper.updateById(entity) > 0;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(List<Long> idList) {

        removeByIds(idList);
    }
    @Override
    public List<SysRadioDetailVO> getRadioDetailArray() {

        return baseMapper.getRadioDetailArray();
    }
    @Override
    public List<SysRadioDetailVO> qryPaperRadioList(SysRadioDetailQuery radioDetailQryDto) {

        return baseMapper.qryPaperRadioList(radioDetailQryDto);
    }
    @Override
    public List<SysRadioDetailVO> qryPaperRadioCondition(SysRadioDetailQuery radioDetailQryDto) {

        return baseMapper.qryPaperRadioCondition(radioDetailQryDto);
    }
    @Override
    public PageResult<SysRadioDetailVO> qryRadioDetailListPage(SysRadioDetailQuery query) {
        IPage<SysRadioDetailEntity> page = baseMapper.qryRadioDetailListPage(getPage(query), query);

        return new PageResult<>(SysRadioDetailConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
    }
}
